﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Trackr.Core.Entities
{
	public class TimeItem
	{
		private string _task;
		private int _id;
		private DateTime _startDate;
		private double _runningSeconds;
		public TimeItem() { }
		public TimeItem(string task)
		{
			_task = task;
			_startDate = DateTime.Now;
			_id = -1;
		}
		public int Id
		{
			get { return _id; }
			set { _id = value; }
		}

		public string Task
		{
			get { return _task; }
			set { _task = value; }
		}
		public double RunningSeconds
		{
			get { return _runningSeconds; }
			set { _runningSeconds = value; }
		}
		public DateTime StartDate
		{
			get { return _startDate; }
			set { _startDate = value; }
		}
		public TimeSpan GetDuration()
		{
			if (_runningSeconds == 0)
				return DateTime.Now.Subtract(StartDate);
			return TimeSpan.FromSeconds(_runningSeconds);
		}
		public void AddDuration(TimeSpan time)
		{
			AddDuration(time.TotalSeconds);
		}
		public void AddDuration(double seconds)
		{
			_runningSeconds = _runningSeconds + seconds;
		}
		public IProject GetProject()
		{
			throw new NotImplementedException();
		}
	}
}
